import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/create/index',
    name: 'Home',
    hidden: true
  },

  {
    path: '/create',
    component: Layout,
    name: 'Create',
    redirect: '/create/index',
    meta: { title: '创建账号', icon: 'user' },
    children: [
      {
        path: 'index',
        component: () => import('@/views/create/index'),
        meta: { title: '创建账号', icon: 'user' }
      }
    ]
  },

  {
    path: '/user',
    component: Layout,
    name: 'User',
    redirect: '/user/index',
    meta: { title: '用户信息', icon: 'table' },
    children: [
      {
        path: 'index',
        name: 'Index',
        component: () => import('@/views/user/index'),
        meta: { title: '用户列表', icon: 'table' }
      },
      {
        path: 'detail',
        name: 'Detail',
        component: () => import('@/views/user/detail/index'),
        meta: { title: '用户详情', icon: 'table' },
        hidden: true
      }
    ]
  },

  {
    path: '/list',
    component: Layout,
    name: 'List',
    redirect: '/list/upload',
    meta: { title: '记录详情', icon: 'example' },
    children: [
      {
        path: 'upload',
        name: 'Upload',
        component: () => import('@/views/list/upload/index'),
        meta: { title: '上传文件', icon: 'form' }
      },
      {
        path: 'analyse',
        name: 'Analyse',
        component: () => import('@/views/list/analyse/index'),
        meta: { title: '应用分析', icon: 'tree' }
      },
      {
        path: 'recharge',
        name: 'Recharge',
        component: () => import('@/views/list/recharge/index'),
        meta: { title: '充值列表', icon: 'nested' }
      },
      {
        path: 'cash',
        name: 'Cash',
        component: () => import('@/views/list/cash/index'),
        meta: { title: '提现记录', icon: 'link' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
